{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd>&nbsp;</dd>
				<dd><a href="wood_help.html"><i class="iconfont">&#xe649;</i>帮助文档</a></dd>
			</dl>
		</div>
		<div class="content">
			<div class="release">
				<dl>
					<dt><i class="iconfont">&#xe649;</i> <b>{{.title}}说明</b><br>
						下方是{{.title}}列表,可以进行添加,修改,删除<br>
						<p>产品栏目分类第二级分类可以添加产品的属性</p>
						<p>产品一级分类的图片用于电脑端的显示,二级和三级分类的图标用于移动端的显示</p>
					</dt>
					<dd><a href="{{$.A_url}}"><button type="button" class="button">添加栏目</button></a></dd>
				</dl>
			</div>

			<table class="table">
				<thead><th>图标</th><th>名称</th><th>排序</th><th>时间</th><th>操作</th></thead>
				{{range .info}}
				<tr id="{{.id}}" class="province" status="0">
					<td class="center"><img src="{{.pathname}}" class="img-1" onerror="javascript:this.src='/static/img/admin/img-no.png'"></td>
					<td>
						栏目名： <b style="color:#a87848">{{.name}}</b>(<!-- <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/all/ensign-1.png" class="ensign"> --> ID：{{.id}} ）<br>
						英文名：{{.english}}<br>
						上级栏目：<mark>{{if .pname}}{{.pname}}{{else}}顶级栏目{{end}}</mark><br>
						<b>等级：</b>{{if eq .level "1"}}一{{else if eq .level "2"}}二{{else}}三{{end}}<br>
					</td>
					<td>
						{{.sort}}
					</td>
					<td>
						添加时间：{{.addtime}}<br>
						修改时间：{{.modificationtime}}
					</td>
					<td class="operation">
						{{if eq $.t "p"}} 
						<a href="javascript: void 0" class="proExport" data-id="{{.id}}" target="_blank">导出产品</a><br>
						{{end}}
						<a href="{{$.E_url}}id={{.id}}">编辑</a><br>
						<a class="del" data-id="{{.id}}">删除</a>
					</td>
				</tr>
					{{range .son}}
					<tr id="{{.id}}" class="city" status="0" pid="{{.pid}}" style="display: none;">
						<td class="center"><img src="{{.pathname}}" class="img-1"></td>
						<td>
							栏目名：<b style="color:#00BFFF">{{.name}}</b>（<!-- <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/all/ensign-1.png" class="ensign"> --> ID：{{.id}} ）<br>
							英文名：{{.english}}<br>
							上级栏目：<mark>{{if .pname}}{{.pname}}{{else}}顶级栏目{{end}}</mark><br>
							<b>等级：</b>{{if eq .level "1"}}一{{else if eq .level "2"}}二{{else}}三{{end}}<br>
						</td>
						<td>
							{{.sort}}
						</td>
						<td>
							添加时间：{{.addtime}}<br>
							修改时间：{{.modificationtime}}
						</td>
						<td class="operation">
							{{if eq $.t "p"}}
							<a href="javascript: void 0" class="proExport" data-id="{{.id}}" target="_blank">导出产品</a><br>
							{{end}}
							{{if eq $.t "p"}}
							<a href="/admin/product/column_content?id={{.id}}">属性</a><br>
							{{end}}
							<a href="{{$.E_url}}id={{.id}}">编辑</a><br>
							<a class="del" data-id="{{.id}}">删除</a>
						</td>
					</tr>
						{{range .son}}
						<tr id="{{.id}}" class="area" pid="{{.pid}}" style="display: none;">
							<td class="center"><img src="{{.pathname}}" class="img-1"></td>
							<td>
								栏目名：<b style="color:#1aad19">{{.name}}</b> （<!-- <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/all/ensign-1.png" class="ensign"> --> ID：{{.id}} ）<br>
								英文名：{{.english}}<br>
								上级栏目：<mark>{{if .pname}}{{.pname}}{{else}}顶级栏目{{end}}</mark><br>
								<b>等级：</b>{{if eq .level "1"}}一{{else if eq .level "2"}}二{{else}}三{{end}}<br>
							</td>
							<td>
								{{.sort}}
							</td>
							<td>
								添加时间：{{.addtime}}<br>
								修改时间：{{.modificationtime}}
							</td>
							<td class="operation">
								{{if eq $.t "p"}}
								<a href="javascript: void 0" class="proExport" data-id="{{.id}}" target="_blank">导出产品</a><br>
								{{end}}
								<a href="{{$.E_url}}id={{.id}}">编辑</a><br>
								<a class="del" data-id="{{.id}}">删除</a>
							</td>
						</tr>
						{{end}}
					{{end}}
				{{end}}
				{{if ne .paginator.totalpages 1}}
					<tr>
						<td  colspan="5">
							<div class="paging">
								{{if ne .paginator.currpage 1}}
								<a href="{{$.url}}page={{.paginator.firstpage}}">首页</a>
								<a href="{{$.url}}page={{.paginator.prevpage}}">&lt;&lt;</a>
								{{else}}
								<a class="disable">首页</a>
								<a class="disable">&lt;&lt;</a>
								{{end}}
								{{range $index,$page := .paginator.pages}}
								{{if eq $.paginator.currpage $page}} 
								<a class="no">{{$page}}</a>
								{{else}}
								<a href="{{$.url}}page={{$page}}">{{$page}}</a>
								{{end}}
								{{end}}
								{{if eq .paginator.currpage .paginator.totalpages}}
								<a class="disable">&gt;&gt;</a>
								<a class="disable">尾页</a>
								{{else}}
								<a href="{{$.url}}page={{.paginator.nextpage}}">&gt;&gt;</a>
								<a href="{{$.url}}page={{.paginator.totalpages}}">尾页</a>
								{{end}}
							</div>
						</td>
					</tr>
				{{end}}
			</table>


		</div>
	</article>
</section>

<footer><!-- 系统监控内容 --></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
	$('.del').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要删除这条数据吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:'mt_column',id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('删除成功');
						$('#'+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.province').click(function(){
		var id=$(this).attr('id')
		var status=$(this).attr('status')
		if (status==0){
			$('tr[pid='+id+']').css('display','table-row')
			$(this).attr('status','1')
		}else{
			$('tr[pid='+id+']').css('display','none')
			$(this).attr('status','0')
			$('tr[pid='+id+']').each(function(){
				var id2=$(this).attr("id")
				$('tr[pid='+id2+']').css('display','none')
			})
		}
	})
	$('.city').click(function(){
		var id=$(this).attr('id')
		var status=$(this).attr('status')
		if (status==0){
			$(this).attr('status','1')
			$('tr[pid='+id+']').css('display','table-row')
		}else{
			$(this).attr('status','0')
			$('tr[pid='+id+']').css('display','none')
		}
	})
	$('.proExport').click(function () {
		var id = $(this).attr('data-id')
		var timer = null
		var once = 0
		$('.animated').show()
		$('body').toast({
	        position:'fixed',
	        animateIn:'fadeIn',
	        animateOut:'fadeOut',
	        content:'导出中...',
	        duration:'99999999',
	        isCenter:true,
	    });
		function fetch() {
			$.ajax({
				url: '/admin/getproduct',
				data: {cid: id, once: once},
				timeout: 1000,
				success: function (res) {
					if (res.status == 1) {
						clearInterval(timer)
						$('.animated').hide()
						window.location = res.pathname
					} else if (res.status == 0) {
						clearInterval(timer)
						$('.animated').hide()
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})
		}
		fetch()
		once = 1
		timer = setInterval(fetch, 1000)
	})
</script>
</body>
</html>
